package com.financing.controller.system;
import java.util.Date;

import com.financing.model.system.Task;
import com.financing.model.user.User;
import com.financing.service.user.UserService;
import com.financing.util.Json;
import com.jfinal.aop.Clear;
import com.jfinal.core.Controller;

public class TaskController extends Controller {
	private UserService user = new UserService();

	/**
	 *  创建任务
	 */
	@Clear
	public void index() {
		User u = user.findByMobile(getPara("mobile"));
		if(u!=null) {
			Task task = new Task();
			task.setUserId(u.getId());
			task.setMobile(u.getMobile());
			task.setPlat(getPara("plat"));
			task.setCode(getPara("code"));
			task.setStatus("process");
			task.setCreateTime(new Date());
			task.save();
			renderJson(Json.ok("任务保存成功！"));
		}else {
			renderJson(Json.error("用户不存在！"));
		}
	}
}
 